package com.iwomy.secureplat.platform.service.impl;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iwomy.secureplat.platform.dto.BasicEventTypeDTO;
import com.iwomy.secureplat.platform.entity.BasicEventTypeEntity;
import com.iwomy.secureplat.platform.mapper.BasicEventTypeMapper;
import com.iwomy.secureplat.platform.service.BasicEventTypeService;
import org.springframework.stereotype.Service;
/**
 * 事件类型表
 *
 * @author pig
 * @date 2023-11-13 17:05:27
 */
@Service
public class BasicEventTypeServiceImpl extends ServiceImpl<BasicEventTypeMapper, BasicEventTypeEntity> implements BasicEventTypeService {
	@Override
	public Page getBasicEventTypePage(Page page, BasicEventTypeDTO basicEventTypeDTO) {
		LambdaQueryWrapper<BasicEventTypeEntity> wrapper = Wrappers.lambdaQuery();

		if (StrUtil.isNotEmpty(basicEventTypeDTO.getTypeName())) {
			wrapper.like(BasicEventTypeEntity::getTypeName, basicEventTypeDTO.getTypeName());
		}

		if (ArrayUtil.isNotEmpty(basicEventTypeDTO.getCreateTime())) {
			wrapper.ge(BasicEventTypeEntity::getCreateTime, basicEventTypeDTO.getCreateTime()[0]).le(BasicEventTypeEntity::getCreateTime,
					basicEventTypeDTO.getCreateTime()[1]);
		}

		return baseMapper.selectPage(page, wrapper);
	}
}